package com.ruoyi.project.mall.service.impl;


import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.bootdo.PageHelperUtils;
import com.ruoyi.common.utils.bootdo.R;
import com.ruoyi.project.mall.dao.MallNewDao;
import com.ruoyi.project.mall.domain.MallNewDO;
import com.ruoyi.project.mall.service.MallNewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class MallNewServiceImpl implements MallNewService {
	@Autowired
	private MallNewDao mallNewDao;
	
	@Override
	public MallNewDO get(String id){
		return mallNewDao.get(id);
	}
	
	@Override
	public List<MallNewDO> list(Map<String, Object> map){
		return mallNewDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return mallNewDao.count(map);
	}
	
	@Override
	public int save(MallNewDO mallNew){
		return mallNewDao.save(mallNew);
	}
	
	@Override
	public int update(MallNewDO mallNew){
		return mallNewDao.update(mallNew);
	}
	
	@Override
	public int remove(String id){
		return mallNewDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return mallNewDao.batchRemove(ids);
	}

    @Override
    public List<MallNewDO> likeList(Map<String, Object> map){
        return mallNewDao.likeList(map);
    }
    @Override
    public int likeListCount(Map<String, Object> map){
        return mallNewDao.likeListCount(map);
    }

    @Override
    public R getHotNews() {

		List<Map<String,Object>> list = mallNewDao.getHotNews();
		return R.ok().put("data",list);

    }

	@Override
	public R getNewsInfo(Map<String, Object> map) {
		MallNewDO mallNewDO = mallNewDao.get(map.get("newsId").toString());
		return R.ok().put("data",mallNewDO);
	}

	@Override
	public R getNewsList(Map<String, Object> params) {
		PageHelperUtils.page(params);
		List<Map<String,Object>> list = mallNewDao.getNewsList(params);
		PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(list);
		return R.ok().put("data",pageInfo);
	}


}
